package com.shen.langchain4j.controller;

import dev.langchain4j.model.chat.ChatModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 与springboot集成，流行集成的控制层接口
 */
@Slf4j
@RestController
@RequestMapping(value = "/popular")
public class PopularIntegrationsController {
    @Autowired
    private ChatModel chatModel;

    @GetMapping("/chat")
    public String chatModel(@RequestParam(value = "prompt", defaultValue = "你是谁") String prompt) {
        return chatModel.chat(prompt);
    }
}
